package com.tinysand.advert.search.vo;

import com.tinysand.advert.index.support.AdvertObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author TINY
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SearchResponse {
    public Map<String, List<Creative>> adSlot2Ads = new HashMap<>();

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class Creative {
        private Long adId;
        private String adUrl;
        private Integer width;
        private Integer height;
        private Integer type;
        private Integer materialType;

        // 展示url
        private List<String> showMonitorUrl =
                Arrays.asList("www.tinysand.com", "www.tinysand.com");

        // 点击监测url
        private List<String> clickMonitorUrl =
                Arrays.asList("www.tinysand.com", "www.tinysand.com");
    }

    public static Creative convert(AdvertObject advertObject) {
        Creative creative = new Creative();
        creative.setAdId(advertObject.getAdId());
        creative.setAdUrl(advertObject.getAdUrl());
        creative.setWidth(advertObject.getWidth());
        creative.setHeight(advertObject.getHeight());
        creative.setType(advertObject.getType());
        creative.setMaterialType(advertObject.getMaterialType());
        return creative;
    }
}
